package com.jwater.core.manager.job;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import com.jwater.core.common.InitLogger;
import com.jwater.core.manager.common.conf.JobConfParse;
import com.jwater.core.manager.common.model.JobInfo;

/**
 * @description:定时任务入口类
 * @author: jnner
 * @createDate: 2021/2/5
 * @version: 1.0
 */
public class JobMain {
    protected static Logger logger = LoggerFactory.getLogger(JobMain.class);

    public static void main(String[] args) {
        String regionName = args[0];
        String deployName = args[1];
        String groupName = args[2];
        String jobName = args[3];
        long time = Long.parseLong(args[4]);
        InitLogger.initJob(regionName, deployName, groupName, jobName);
        logger.info("regionName:" + regionName + ",deployName:" + deployName + ",groupName:" + groupName + ",jobName:"
                + jobName + ",time:" + time);
        JobConfParse jobConf = new JobConfParse();
        jobConf.parse();
        JobInfo jobInfo = jobConf.getJobInfo(regionName, deployName, groupName, jobName);
        if (jobInfo == null) {
            logger.error("can not find jobInfo");
            return;
        }
        JobNode jobNode = new JobNode(jobInfo, time);
        jobNode.start();
    }
}
